simulation results/plot in 3d.R

library(tidyverse); theme_set(theme_minimal(28))
library(plotly)

cov3d <- read_rds("~/Documents/Coding/RStudio/Research/IntegratedLikelihood.R/simulation results/res_3d_coverage_big.rds")
wid3d <- read_rds("~/Documents/Coding/RStudio/Research/IntegratedLikelihood.R/simulation results/res_3d_width.rds")

mutate(
  cov3d,
  `k=0.45` = case_when(
    (N <= 150) ~ `k=0.45`
  ),
  `k=0.55` = case_when(
    (N >= 150 & N <= 400) ~ `k=0.55`
  ),
  `k=0.6` = case_when(
    (N >= 400) ~ `k=0.6`
  ),
  color = 15
) -> new_data

ps <- seq(from = 0.05, to = 0.95, by = 0.05)
ns <- seq(from = 50, to = 700, by = 25)

mw <- matrix(new_data$mW, length(ps), length(ns))
il <- matrix(new_data$IL, length(ps), length(ns))
il_045 <- matrix(new_data$`k=0.45`, length(ps), length(ns))
il_055 <- matrix(new_data$`k=0.55`, length(ps), length(ns))
il_060 <- matrix(new_data$`k=0.6`, length(ps), length(ns))
ninetyfive <- matrix(0.95, length(ps), length(ns))

plot_ly(x = ns, y = ps, showscale = FALSE, colors = c("grey", "white")) %>%
  add_surface(z = il_045) %>%
  add_surface(z = il_055) %>%
  add_surface(z = il_060) %>%
  # add_surface(z = ninetyfive, opacity = 0.75, surfacecolor = list(colors = "red")) %>%
  add_markers(
    data = new_data, x = ~N, y = ~p, z = ~IL, inherit = FALSE,
    marker = list(color = "black", opacity = 0.25), showlegend = FALSE
    ) %>%
  layout(
    scene = list(
      xaxis = list(title = "N"),
      yaxis = list(title = "p"),
      zaxis = list(
        title = "Coverage",
        nticks = 4,
        range = c(0.93, 1)
      )
    )
  )

plot_ly(x = ns, y = ps, showscale = FALSE, colors = c("black")) %>%
  add_surface(z = il_045, opacity = 0.95) %>%
  add_surface(z = il_055, opacity = 0.95) %>%
  add_surface(z = il_060, opacity = 0.95) %>%
  add_markers(
    data = new_data, x = ~N, y = ~p, z = ~IL, inherit = FALSE,
    marker = list(color = "grey", opacity = 0.5), showlegend = FALSE
  ) %>%
  layout(
    scene = list(
      xaxis = list(title = "N"),
      yaxis = list(title = "p"),
      zaxis = list(
        title = "Coverage",
        nticks = 4,
        range = c(0.93, 1)
      )
    )
  )

# plot_ly(x = ns, y = ps, showscale = FALSE, colors = c("grey", "black")) %>%
#   add_surface(z = mw, surfacecolor = color2) %>%
#   add_surface(z = il_050, surfacecolor = color3) %>%
#   add_surface(z = il, surfacecolor = color1) %>%
#   add_surface(z = ninetyfive, opacity = 0.90) %>%
#   layout(
#     scene = list(
#       xaxis = list(title = "N"),
#       yaxis = list(title = "p"),
#       zaxis = list(
#         title = "Coverage",
#         nticks = 4,
#         range = c(0.80, 1)
#       )
#     )
#   )
BriceonWiley/IntegratedLikelihood.R documentation built on Aug. 21, 2020, 11 p.m.